import { getListApi } from "@/api/zb";
import { ListZbParam } from "@/api/zb/ZbModel";

import { nextTick, onMounted, ref } from "vue";
import { reactive } from "vue";


//表格相关业务的抽离
export default function useZbTable() {
    //表格高度
    const tableHeight = ref(0)

    //列表查询的参数
    const listParam = reactive<ListZbParam>({
 
 
        zhouBaoMingCheng: '',
      
 
    })
    //接受表格数据
    const tableList = ref([])
    //列表
    const getList = async () => {
        let res = await getListApi(listParam);
        console.log(res)
        if (res && res.code == 200) {
            tableList.value = res.data;
        }
    }

    //搜索
    const searchBtn = () => {
        getList()
    }
    //重置
    const resetBtn = () => {
        listParam.zhouBaoMingCheng = '';
        getList()
    }

    onMounted(() => {
        getList()
        //计算表格的高度
        nextTick(() => {
            tableHeight.value = window.innerHeight - 220
        })
    })
    return {
        listParam,
        searchBtn,
        resetBtn,
        getList,
        tableList,
        tableHeight
    }
}
